/*
 * Copyright(c) 2018 优居科技 All rights reserved.
 * distributed with this file and available online at
 * http://www.yjyz.com/
 */
package com.zb.api.business.controller;


import com.zb.api.business.dto.PosPlanDto;
import com.zb.api.business.dto.PosUserCollectDto;
import com.zb.api.business.service.IPosUserCollectService;
import com.zb.api.common.models.Page;
import com.zb.api.common.models.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


/**
* 用户收藏表
 *
 * @author cwp
 * @version v1.0
 * @CreationTime: - 2022-02-08 14:19:31
 * @Description:
 */
@Api("用户收藏表")
@RestController
@Slf4j
@RequestMapping("/PosUserCollect")
public class PosUserCollectController {

    @Resource
    private IPosUserCollectService posUserCollectService;

    @GetMapping("/lists")
    @ApiOperation(value="获取分页用户收藏表数据", nickname = "posUserCollectList")
    public Result<Page<PosUserCollectDto>> posUserCollectList(@RequestParam(defaultValue = "1") @ApiParam(name = "pageNo", value = "当前页") int pageNo,
                                                              @RequestParam(defaultValue = "10") @ApiParam(name = "pageSize", value = "每页记录数") int pageSize,
                                                              PosUserCollectDto posUserCollectDto){
        return new Result("查询成功", posUserCollectService.getPosUserCollectList(pageNo, pageSize, posUserCollectDto));
    }

    @GetMapping("/{id}")
    @ApiOperation(value="获取用户收藏表", nickname = "getPosUserCollect")
    public Result<PosUserCollectDto> getPosUserCollect(@PathVariable("id") String id) {
        return new Result("查询成功", posUserCollectService.get(id));
    }

    @PutMapping
    @ApiOperation(value="更新用户收藏表", nickname = "updatePosUserCollect")
    public Result<Integer> updatePosUserCollect(@RequestBody PosUserCollectDto posUserCollectDto) {
        return new Result("修改成功", posUserCollectService.update(posUserCollectDto));
    }

    @PostMapping("/addUserCollect")
    @ApiOperation(value="插入用户收藏表", nickname = "insertPosUserCollect")
    public Result<Integer> insertPosUserCollect(@RequestBody PosUserCollectDto posUserCollectDto) {
        return new Result("录入成功", posUserCollectService.insert(posUserCollectDto));
    }

    @PostMapping("/delUserCollect")
    @ApiOperation(value="移除用户收藏表", nickname = "delUserCollect")
    public Result<Integer> delUserCollect(@RequestBody PosUserCollectDto posUserCollectDto) {
        return new Result("操作成功", posUserCollectService.delete(posUserCollectDto.getId()));
    }

    @PostMapping("/getUserCollectList")
    @ApiOperation(value="查询用户收藏方案列表", nickname = "getUserCollectList")
    public Result<Page<PosPlanDto>> getUserCollectList(@RequestBody PosUserCollectDto posUserCollectDto) {
        return new Result("查询成功", posUserCollectService.getUserCollectList(posUserCollectDto));
    }

}
